<template>
	<view class="main-page" style="align-items: center;">
		<textarea
			v-model="advice"
			class="input-area"
			placeholder-class="font-999-32"
			placeholder="请输入您需要我们改进的地方…"
		></textarea>
		<input 
			class="input-box"
			v-model="mobile"
			placeholder-class="font-999-32"
			placeholder="请输入您的联系方式"
			type="number"
		/>
		<text :class="[advice && mobile ? 'confirm-btn' : 'confirm-btn-negative']" @click="handleCommit">提交</text>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				advice:'',
				mobile:''
			}
		},
		methods: {
			handleCommit(){
				if (!this.advice || !this.mobile) return
				
				let that = this
				this.http({
					url:"/pos/user/saveFeedback",
					method:"POST",
					data:{
						intro:this.advice,
						mobile:this.mobile
					},
					success(data){
						let type = 1
						if (data.code != 200){
							type = 2
						}
						
						uni.redirectTo({
							url:'/pages/mine/adviceResult?type=' + type + "&msg=" + data.msg
						})
						
					},
					failed(e){
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	.input-area{
		background: white;
		border-radius: 16rpx;
		margin: 20rpx 30rpx;
		height: 296rpx;
		padding: 24rpx;
		width: calc(100% - 108rpx);
		color: #333333;
		font-size: 32rpx;
	}
	
	.input-box{
		background: white;
		border-radius: 16rpx;
		padding: 26rpx 24rpx;
		color: #333333;
		font-size: 32rpx;
		width: calc(100% - 108rpx);
		margin: 0rpx 30rpx;
	}
	
	.confirm-btn{
		width: calc(100% - 60rpx);
		height: 88rpx;
		background: #F94C4B;
		border-radius: 16rpx;
		margin: 50rpx 30rpx;
		text-align: center;
		line-height: 88rpx;
		color: white;
		font-size: 32rpx;
		font-weight: 600;
	}
	
	.confirm-btn-negative{
		width: calc(100% - 60rpx);
		height: 88rpx;
		background: rgba(249, 76, 75, 0.5);
		border-radius: 16rpx;
		margin: 50rpx 30rpx;
		text-align: center;
		line-height: 88rpx;
		color: white;
		font-size: 32rpx;
		font-weight: 600;
	}
</style>
